<?php


/**
 * 获得指定国家的所有省份
 *
 * @access      public
 * @param       int     country    国家的编号
 * @return      array
 */
function get_itemcat($type = 0, $parent = 0)
{
    $sql = 'SELECT cid, name FROM ' . $GLOBALS['os']->table('tb_itemcat') .
            " WHERE  parent_cid = '$parent'";  
    return $GLOBALS['db']->GetAll($sql);
}

define('IN_OS', true);
define('INIT_NO_USERS', true);
define('INIT_NO_SMARTY', true);



require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/cls_json.php');

header('Content-type: text/html; charset=' . OS_CHARSET);

$type   = !empty($_REQUEST['type'])   ? intval($_REQUEST['type'])   : 0;
$parent = !empty($_REQUEST['parent']) ? intval($_REQUEST['parent']) : 0;

$arr['regions'] = get_itemcat($type, $parent);
$arr['type']    = $type;
$arr['target']  = !empty($_REQUEST['target']) ? stripslashes(trim($_REQUEST['target'])) : '';
$arr['target']  = htmlspecialchars($arr['target']);
 
$json = new JSON;

die( $json->encode($arr));
echo $json->encode($arr);

?>